package com.meixiang.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.meixiang.R;
import com.meixiang.entity.ViewHolder;
import com.meixiang.main.MXApplication;
import com.meixiang.util.DensityUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zys on 2016/4/6.
 *  显示输入密码适配器
 */
public class ShowGridAdapter extends BaseAdapter {
    private List<String> showList=new ArrayList<>();
    private LayoutInflater inflater;
    public ShowGridAdapter(Context context){
        inflater=LayoutInflater.from(context);
    }
    public void UpdateData(List<String> showList){
        this.showList=showList;
        notifyDataSetInvalidated();
    }
    @Override
    public int getCount() {
        return showList.size();
    }

    @Override
    public Object getItem(int position) {
        return showList.get(position);

    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder=null;
        if (convertView==null){
            convertView=inflater.inflate(R.layout.payment_key_itme,null);
            viewHolder=new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }else{
            viewHolder= (ViewHolder) convertView.getTag();
        }
        viewHolder.viewright.setBackgroundResource(R.color.input_box);
        viewHolder.viewright.getLayoutParams().width= DensityUtil.dip2px(MXApplication.mApp, 1);
        viewHolder.viewtop.setVisibility(View.GONE);
        if (position==5){
            viewHolder.viewright.setVisibility(View.GONE);
        }
        if (showList.get(position).equals("")){
            viewHolder.itemtxt.setText("");
        }else{
            viewHolder.itemtxt.setText("●");
        }
        return convertView;
    }

}
